package com.monkeybrother.common;

import java.util.Date;


    public class ScfResult<T> {

    private int code;

    private String message;

    private T data;

    public ScfResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public ScfResult(AbstractBaseEnum baseEnum) {
        this.code = baseEnum.getCode();
        this.message = baseEnum.getMessage();
    }


    public ScfResult(AbstractBaseEnum baseEnum, T data) {
        this(baseEnum);
        this.data = data;
    }

    /**
     *
     * @param baseEnum
     * @param data
     * @return
     */
    public static ScfResult<Object> fail(AbstractBaseEnum baseEnum, Object data) {
        return new ScfResult<>(baseEnum, data);
    }


    public static ScfResult<Object> success(Object data) {
        return new ScfResult<>(ScfBaseEnum.SUCCESS.getCode(), ScfBaseEnum.SUCCESS.getMessage(), data);
    }

    public static ScfResult<Object> fail() {
        return new ScfResult<>(ScfBaseEnum.FAIL);
    }

    public boolean isSuccess() {
        return ScfBaseEnum.SUCCESS.getCode() == this.code;
    }

    public boolean isFail() {
        return !this.isSuccess();
    }


}
